package cn.com.qingz.modules.user.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import cn.com.qingz.modules.system.service.impl.GeneralServiceImpl;
import cn.com.qingz.modules.user.mapper.*;
import cn.com.qingz.modules.user.model.*;
import cn.com.qingz.modules.user.service.*;
import cn.com.qingz.modules.user.vo.*;
import org.springframework.util.CollectionUtils;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class BillGoodsServiceImpl  extends GeneralServiceImpl<BillGoods> implements BillGoodsService  {
	
	@Autowired
	private BillGoodsMapper  billgoodsMapper;


	
	public PageList<BillGoods> queryForPage(Object condition, int page, int limit) {
		
		return  billgoodsMapper.queryForPage((BillGoodsSearchCondition) condition,  new PageBounds(page, limit));
	}

	public void doSave(List<BillGoods> list) {
		if(! CollectionUtils.isEmpty(list)){
			Integer designId = list.get(0).getDesignId();
			BillGoods b = new BillGoods();
			b.setDesignId(designId);
			billgoodsMapper.delete(b);

			for (BillGoods billGoods : list) {
				billgoodsMapper.insert(billGoods);
			}
		}
	}
}
